package com.heima.article.feign;

import com.heima.apis.article.IArticleClient;
import com.heima.article.service.ApArticleConfigService;
import com.heima.article.service.ApArticleService;
import com.heima.article.service.ApCollectionService;
import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.article.pojos.ApArticle;
import com.heima.model.article.pojos.ApArticleConfig;
import com.heima.model.article.pojos.ApCollection;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmCommentListDto;
import com.heima.model.wemedia.dtos.WmStatistics3Dto;
import com.heima.model.wemedia.pojos.WmNewsStatistics;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class ArticleClient implements IArticleClient {

    @Autowired
    private ApArticleService apArticleService;
    @Autowired
    private ApArticleConfigService apArticleConfigService;
    @Autowired
    private ApCollectionService apCollectionService;


    @PostMapping("/api/v1/article/save")
    @Override
    public ResponseResult saveAppArticle(@RequestBody ArticleDto articleDto) {
        return apArticleService.saveAppArticle(articleDto);
    }

    @Override
    @PostMapping("/api/v1/article/findCount")
    public Integer findCount(@RequestBody WmStatistics3Dto wmStatistics3Dto){
        return apArticleService.findCount(wmStatistics3Dto);
    }

    @PostMapping("/api/v1/article/comment_list")
    public ResponseResult commentList(@RequestBody WmCommentListDto dto){
        return apArticleService.commentList(dto);
    }

    @Override
    @PostMapping("/api/v1/article/findArticle")
    public ApArticle findArticle(@RequestBody Long articleId){
        return apArticleService.getById(articleId);
    }

    @Override
    @PostMapping("/api/v1/article/findByPublishTime")
    public List<WmNewsStatistics> findByPublishTime(@RequestBody WmStatistics3Dto wmStatistics3Dto){
        return apArticleService.findByPublishTime(wmStatistics3Dto);
    }

    @Override
    @PostMapping("/api/v1/article/findArticleConfig")
    public ApArticleConfig findArticleConfig(@RequestBody Long articleId){
        return apArticleConfigService.findByArticleId(articleId);
    }

    @Override
    @PostMapping("/api/v1/article/findArticleCollection")
    public ApCollection findArticleCollectionById(@RequestBody Long articleId){
        return apCollectionService.findArticleCollectionById(articleId);
    }

}
